<template>
  <div class="flex-column" style="justify-content: space-between;height: 100%;position: relative;flex: 1">
    <div class="search">
      <a-input-group compact>
        <a-select v-model:value="MyTable.param.is_tt" style="width: 30%" allow-clear
                  @change="onSelect">
          <a-select-option value="1">天台</a-select-option>
          <a-select-option value="2">异常人员监控</a-select-option>
          <a-select-option value="3">其他</a-select-option>
        </a-select>
        <a-input v-model:value="MyTable.param.name" style="width: 50%"/>
        <a-button style="width: 20%" type="primary" @click="MyTable.getDatas()">搜索</a-button>
      </a-input-group>
    </div>
    <CMyTable style="position:absolute;width: 100%;"></CMyTable>
    <BtnGroup style="position:absolute;bottom: 0;" close-name="还原" submit-name="保存" @close="close" @submit="save"></BtnGroup>

  </div>

</template>

<script setup>

import {reactive} from "@vue/reactivity";
import {addTableConfig} from "@/components/customs/camera-set/data";
import {provide} from "vue";
import CMyTable from "@/components/my-table/index.vue";
import BtnGroup from "@/components/customs/btn-group";
import {CameraEdit} from "@/common/customs/setting";

const MyTable = reactive({
  onSearch: null,
  param: {
    name: "",
    is_tt: "",
  },
});

const emit = defineEmits(["submit", "close"]);
provide("MyTable", MyTable);
addTableConfig(MyTable);
const save = () => {
  // emit("submit", MyTable.datas);
  MyTable.datas.forEach(async item => {
    const api = new CameraEdit()
    api.query(['jk-edit',item.id])
    api.data({
      is_tt:item.is_tt,
      ssl:item.ssl,
    })
    await api.send()
  })

};
const onSelect = () => {
  MyTable.pageConfig.onChange(1,8)
};
const close = () => {
  MyTable.param.name = "";
  MyTable.param.is_tt = "";
  MyTable.pageConfig.onChange(1, 8);
};
</script>

<style lang="less" scoped>
@import "./index.less";
</style>
